//
//  uiWidget.h
//  trail-map-editor
//
//  Created by Giorgio Tino on 3/22/13.
//
//

#ifndef __trail_map_editor__uiWidget__
#define __trail_map_editor__uiWidget__

#include <plib/ul.h>

class uiView;

// Abstract widget
class uiWidget
{
    public:
        ~uiWidget() { delete name;};
        virtual void setName(const char* name) // The widget owns the name
        {
            if(!ulStrEqual(this->name, name))
            {
                if(this->name)
                {
                    delete this->name;
                    this->name = NULL;
                }
                
                if(name)
                    this->name = ulStrDup(name);
            }
        }
        virtual char* getName() const {return name;}
        virtual void setView(uiView* view) {this->view = view;}
        virtual uiView* getView() const {return view;}
    
        virtual uiWidget* getFirstChildWidget() const = 0;
        virtual uiWidget* getNextWidget() const = 0;
    
    private:
        char* name;
        uiView* view;
};

#endif /* defined(__trail_map_editor__uiWidget__) */
